#include <bits/stdc++.h>
using namespace std;

int main(void) {
	char str[105][105];
	int arr[105][105];
	int x, y;
	cin >> x >> y;
	for (int i = 0; i < 105; i++) {
		for (int j = 0; j < 105; j++) {
			arr[i][j] = 0;
		}
	}
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			cin >> str[i][j];
			if (str[i][j] == '*') {
				arr[i - 1][j]++;
				arr[i - 1][j - 1]++;
				arr[i - 1][j + 1]++;
				arr[i][j - 1]++;
				arr[i][j + 1]++;
				arr[i + 1][j]++;
				arr[i + 1][j - 1]++;
				arr[i + 1][j + 1]++;
			}
		}
	}
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= y; j++) {
			if (str[i][j] == '*') {
				cout << '*';
			} else {
				cout << arr[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}